﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using BusinessLogicLayer;
using Entities;

namespace QLNhaSach.Modules.ThongTin
{
    public partial class DanhSachBaoCaoCongNo : UserControl
    {
        DataTable table = new DataTable();
        public DanhSachBaoCaoCongNo()
        {
            InitializeComponent();
            table.Columns.Add("STT");
            table.Columns.Add("Tháng");
            table.Columns.Add("Năm");
            table.Columns.Add("Tên khách hàng");
            table.Columns.Add("Nợ đầu");
            table.Columns.Add("Phát sinh");
            table.Columns.Add("Nợ cuối");
            KhachHangBO khbo = new KhachHangBO();
            BaoCaoCongNoBO bccnbo = new BaoCaoCongNoBO();
            DataTable dt = bccnbo.layDanhSachBaoCaoCongNo();
            int i = 1;
            foreach (DataRow dr in dt.Rows)
            {
                KhachHang kh = new KhachHang();
                kh = khbo.layThongTinKhachHang(int.Parse(dr["CTBCCN_MAKHACHHANG"].ToString()));
                table.Rows.Add(i++, dr["BCCN_THANG"].ToString(), dr["BCCN_NAM"].ToString(), kh.HoTenKhachHang, dr["CTBCCN_NODAU"].ToString(), dr["CTBCCN_PHATSINH"].ToString(), dr["CTBCCN_NOCUOI"].ToString());
            }
            gridControl1.DataSource = table;
            //gridView1.Columns["Mã phiếu thu"].Visible = false;
        }

        private void simpleButton7_Click(object sender, EventArgs e)
        {
            Environment.Exit(1);
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            gridControl1.DataSource = null;
            DataTable dt = new DataTable();
            dt.Columns.Add("STT");
            dt.Columns.Add("Tháng");
            dt.Columns.Add("Năm");
            dt.Columns.Add("Tên khách hàng");
            dt.Columns.Add("Nợ đầu");
            dt.Columns.Add("Phát sinh");
            dt.Columns.Add("Nợ cuối");
            KhachHangBO khbo = new KhachHangBO();
            BaoCaoCongNoBO bccnbo = new BaoCaoCongNoBO();
            DataTable ds = bccnbo.layDanhSachBaoCaoCongNo();
            int i = 1;
            foreach (DataRow dr in ds.Rows)
            {
                KhachHang kh = new KhachHang();
                kh = khbo.layThongTinKhachHang(int.Parse(dr["CTBCCN_MAKHACHHANG"].ToString()));
                dt.Rows.Add(i++, dr["BCCN_THANG"].ToString(), dr["BCCN_NAM"].ToString(), kh.HoTenKhachHang, dr["CTBCCN_NODAU"].ToString(), dr["CTBCCN_PHATSINH"].ToString(), dr["CTBCCN_NOCUOI"].ToString());
            }
            gridControl1.DataSource = dt;
        }
    }
}
